package tuanda.soict.firstsun.AbilityPackage;

import java.util.ArrayList;

import tuanda.soict.firstsun.DataPackage.ArmyDataSet;
import tuanda.soict.firstsun.DataPackage.AttributeList;
import tuanda.soict.firstsun.LogicPackage.Army;
import tuanda.soict.firstsun.LogicPackage.Coordinate;
import tuanda.soict.firstsun.LogicPackage.Scenario;

/**
 * @author tuanda_soict_hut
 * @version 0.0.1
 * @since 9-9-2012
 */
public class Retransform_Ability extends Ability implements AttributeList {

	public Retransform_Ability(int id, String name, int range, int area,
			int affect) {
		super(id, name, range, area, affect);
	}

	@Override
	public void mainAct(Army army, Scenario scenario) {
		int id = army.getID();
		int groupID = army.getGroupID();
		int x = army.getLocationX();
		int y = army.getLocationY();

		scenario.removeArmy(id, groupID, x, y);
		ArmyDataSet chosenArmyDataSet = ArmyDataSet.SOLDIER.getArmyData(32);
		Army transformedArmy = null;

		transformedArmy = scenario.addInitialArmy(chosenArmyDataSet, groupID,
				x, y);
		if (transformedArmy != null) {
			transformedArmy.setExperience(army.getExperience()
					+ (abilityLevel + 10) * army.getRank(), armyManager);
			transformedArmy.setLevel(2);
		}
	}

	@Override
	public void calculation(Army army, Scenario scenario) {
		this.setAbilityPoint(Integer.MIN_VALUE);
	}

	@Override
	public ArrayList<Coordinate> calculateAffectedArea(Army army,
			Scenario scenario) {
		ArrayList<Coordinate> temp = new ArrayList<Coordinate>();
		temp.add(new Coordinate(army.getLocationX(), army.getLocationY()));
		return temp;
	}
}
